﻿using System;

namespace NPack.Interfaces
{
    /// <summary>
    /// Rounding modes
    /// </summary>
    public enum RoundingMode
    {
        /// <summary>
        ///
        /// </summary>
        Default = MidpointRounding.AwayFromZero,
        /// <summary>
        /// Just like <see cref="MidpointRounding.ToEven"/>
        /// </summary>
        MidPointRoundingToEven = MidpointRounding.ToEven,
        /// <summary>
        /// Just like <see cref="MidpointRounding.AwayFromZero"/>
        /// </summary>
        MidpointRoundingAwayFromZero = MidpointRounding.AwayFromZero,

        /// <summary>
        /// Java's rint method
        /// </summary>
        JavaRint = MidpointRoundingAwayFromZero + 1,
    }

    /// <summary>
    ///
    /// </summary>
    /// <typeparam name="TComponent"></typeparam>
    public interface IRoundable<TComponent> : IHasOneHalf<TComponent>
    {
        /// <summary>
        /// Gets
        /// </summary>
        /// <returns></returns>
#if DOTNET40

        [System.Diagnostics.Contracts.Pure]
#endif
        TComponent Floor();

        /// <summary>
        ///
        /// </summary>
        /// <param name="nearest"></param>
        /// <returns></returns>
#if DOTNET40

        [System.Diagnostics.Contracts.Pure]
#endif
        TComponent FloorNearest(Int32 nearest);

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
#if DOTNET40

        [System.Diagnostics.Contracts.Pure]
#endif
        TComponent Ceiling();

        /// <summary>
        ///
        /// </summary>
        /// <param name="nearest"></param>
        /// <returns></returns>
#if DOTNET40

        [System.Diagnostics.Contracts.Pure]
#endif
        TComponent CeilingNearest(Int32 nearest);

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
#if DOTNET40

        [System.Diagnostics.Contracts.Pure]
#endif
        TComponent Round();

        /// <summary>
        ///
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
#if DOTNET40

        [System.Diagnostics.Contracts.Pure]
#endif
        TComponent Round(RoundingMode mode);

        /// <summary>
        ///
        /// </summary>
        /// <param name="decimals"></param>
        /// <returns></returns>
#if DOTNET40

        [System.Diagnostics.Contracts.Pure]
#endif
        TComponent Round(Int32 decimals);

        /// <summary>
        ///
        /// </summary>
        /// <param name="decimals"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
#if DOTNET40

        [System.Diagnostics.Contracts.Pure]
#endif
        TComponent Round(Int32 decimals, RoundingMode mode);
    }
}